package org.smr.ministore.controller;

import javax.annotation.Resource;

import org.blade.msg.Message;
import org.blade.utils.Pager;
import org.smr.ministore.entities.GoodsSpecificationGroupOrgan;
import org.smr.ministore.service.GoodsSpecificationGroupOrganService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestBody;


@Controller("GoodsSpecificationGroupOrganController")
public class GoodsSpecificationGroupOrganController {

	@Resource
	private GoodsSpecificationGroupOrganService service;
	
	/**
	 * 保存编辑后的GoodsSpecificationGroupOrgan信息
	 * @param GoodsSpecificationGroupOrgan
	 * @return
	 */
	@ResponseBody
	@RequestMapping(method = RequestMethod.PATCH, value = "/GoodsSpecificationGroupOrgan/edit")
	public Message modify(@RequestBody GoodsSpecificationGroupOrgan GoodsSpecificationGroupOrgan){
		Message msg = new Message();
		
		if(null == GoodsSpecificationGroupOrgan.getId()){
			msg.setStatus(service.save(GoodsSpecificationGroupOrgan));
		}else{
			msg.setStatus(service.updateById(GoodsSpecificationGroupOrgan));
		}
		return msg;
	}
	
	/**
	* 跳转到列表查询GoodsSpecificationGroupOrgan
	 * @return
	 */
	@RequestMapping(method = RequestMethod.GET, value = "/GoodsSpecificationGroupOrgan/list-page")
	public String toList(){
		return "/GoodsSpecificationGroupOrgan/GoodsSpecificationGroupOrgan-list";
	}

	/**
	*  根据id查询GoodsSpecificationGroupOrgan
	* @return
	*/
	@ResponseBody
	@RequestMapping(method = RequestMethod.GET, value = "/GoodsSpecificationGroupOrgan")
	public GoodsSpecificationGroupOrgan get( Long id ){
		return service.queryById(id);
	}


    /**
	 * 分页查询GoodsSpecificationGroupOrgan信息
	 * @param GoodsSpecificationGroupOrgan
	 * @param pageSize
	 * @param pageNum
	 * @return
	 */
	@ResponseBody
	@RequestMapping( value = "/GoodsSpecificationGroupOrgan/list")
	public Pager<GoodsSpecificationGroupOrgan> list(@RequestBody GoodsSpecificationGroupOrgan GoodsSpecificationGroupOrgan , long pageSize, long pageNum ){

		return service.paginate(GoodsSpecificationGroupOrgan, pageSize, pageNum);

	}
	
	
	/**
	 * 根据ID删除GoodsSpecificationGroupOrgan信息
	 * @param id
	 * @return
	 */
	@ResponseBody
	@RequestMapping( value = "/GoodsSpecificationGroupOrgan/remove",method = RequestMethod.DELETE)
	public Message remove( Long id){
		
		Message msg = new Message();
		msg.setStatus(service.deleteById(id));
		return msg;
	}

}
